package com.wxg.config.rocketmq;

import com.wxg.domain.MqConstant;
import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
import org.apache.rocketmq.common.message.MessageQueue;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author void
 * @date 2020/6/1 13:30
 * @desc
 */
@Conditional(value = RocketCondition.class)
@Component
public class IRocketMqStrategy implements AllocateMessageQueueStrategy {
    @Override
    public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll, List<String> cidAll) {
        List<MessageQueue> list = new ArrayList<>();
        list.add(mqAll.get(MqConstant.env-1));
        return list;
    }

    @Override
    public String getName() {
        return "env-based";
    }
}
